package top.yongyan0624.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import top.yongyan0624.pojo.CountCredit;
import top.yongyan0624.pojo.Dept;
import top.yongyan0624.service.*;

import java.util.List;
import java.util.Map;

/**
 * @author Yongyan
 * @description: TODO
 * @date 2020/12/25
 **/
@Controller
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private StudentService studentService;

    @Autowired
    private TeacherService teacherService;

    @Autowired
    private DeptService deptService;

    @Autowired
    private LessonService lessonService;

    @Autowired
    private ClazzService clazzService;

    @Autowired
    private RoomService roomService;

    @RequestMapping("/toIndexPage")
    private String toIndexPage(Model model){
        Integer totalStu = studentService.totalStu();
        model.addAttribute("totalStu",totalStu);
        Integer totalTeacher = teacherService.totalTeacher();
        model.addAttribute("totalTeacher",totalTeacher);
        Integer totalDept = deptService.totalDept();
        model.addAttribute("totalDept",totalDept);
        Integer totalLesson = lessonService.totalLesson();
        model.addAttribute("totalLesson",totalLesson);
        Integer totalClazz = clazzService.totalClazz();
        model.addAttribute("totalClazz",totalClazz);
        Integer totalRoom = roomService.totalRoom();
        model.addAttribute("totalRoom",totalRoom);

        return "indexPage";
    }


    @RequestMapping("/toAnalyzeDeptPage")
    private String toAnalyzeDeptPage(){
        return "analyzeDeptPage";
    }

    @RequestMapping("/findDept")
    @ResponseBody
    private List<Dept> findDept(){
        return deptService.findAllDept();
    }


    @RequestMapping("/toAnalyzeCreditPage")
    private String toAnalyzeCreditPage(){
        return "analyzeCreditPage";
    }

    @RequestMapping("/countCredit")
    @ResponseBody
    private List<CountCredit> countCredit(){
        return lessonService.countCredit();

    }
}
